import { createBrowserRouter } from "react-router-dom"
import LayoutGeek from "@/pages/LayoutGeek/LayoutGeek.js"
import Login from "@/pages/Login/Login.js"
import {AuthRouter} from "@/component/AuthRoute/AuthRouter.js"
/*import Home from "@/pages/LayoutGeek/childrens/Home/Home.js"
import Article from "@/pages/LayoutGeek/childrens/Article/Article.js"
import Publish from "@/pages/LayoutGeek/childrens/Publish/Publish.js"*/
import { lazy, Suspense } from "react"

// 配置路由懒加载
// 1、使用lazy函数对组件进行导入
// 2、使用<Suspense></Suspense>进行包裹
const Home = lazy(() => import('@/pages/LayoutGeek/childrens/Home/Home.js'))
const Article = lazy(() => import('@/pages/LayoutGeek/childrens/Article/Article.js'))
const Publish = lazy(() => import('@/pages/LayoutGeek/childrens/Publish/Publish.js'))


const router = createBrowserRouter([
    {
        path: "/",
        element: <AuthRouter> <LayoutGeek /> </AuthRouter>,
        children: [
            {
                index:true,
                element: <Suspense fallback={"加载中..."}><Home/></Suspense>
            },
            {
                path: '/article',
                element: <Suspense fallback={"加载中..."}><Article/></Suspense>
            },
            {
                path: '/publish',
                element: <Suspense fallback={"加载中..."}><Publish/></Suspense>
            }
        ]
    },
    {
        path: "/login",
        element: <Login />
    }
])

export default router